$(function(){
	
	var storage = "";
	storage = window.localStorage
	var shops = JSON.parse(storage.getItem("shops"))
	// var new_shops = []
	// new_shops = shops
	
	
	
	var sn = shops[shops.length-1].shopname
	console.log(sn)
	var b = parseInt(shops[shops.length-1].money);
	var spl = shops[shops.length-1].shoplis
	
	var results = storage.getItem("choose")
	
	if(results == "yes"){
		$("<div class='have-order'></div>").html(`
			<div class="shop-name">
				<div class="name">
					<span class="sn">`+sn+`</span><i class="iconfont" style="font-size: 0.8rem;">&#xe65c;</i>
					<div class="pay-r">
						<span class="pay-money">`+(b+3)+`</span>
					</div>
				</div>
				<div class="xiala">
					
				</div>
			</div>
		`).appendTo(".have-order")
		$.each(spl,function(i,e){
			if (spl[i] != null) {
				$("<div class='food'></div>").html(`
					<span>`+spl[i].name+`×` + spl[i].num + `</span>
					<span class="money">￥` + spl[i].money + `</span>
				`).appendTo(".xiala")
			}
		})
		$("<div class='food'></div>").html(`
					<span>配送费</span>
					<span class="money">￥3</span>
			`).appendTo(".xiala")
	} else if(results == "no"){
		$("<div class='not-order'></div>").html(`
			<div class="shop-name">
				<div class="name">
					<span class="sn">`+sn+`</span><i class="iconfont" style="font-size: 0.8rem;">&#xe65c;</i>
					<div class="pay-r">
						<span class="pay-money">`+(b+3)+`</span>
						<span class="go">去支付</span>
					</div>
				</div>
				<div class="xiala">
					
				</div>
			</div>
		`).appendTo(".not-order")
		$.each(spl,function(i,e){
			if (spl[i] != null) {
				$("<div class='food'></div>").html(`
					<span>`+spl[i].name+`×` + spl[i].num + `</span>
					<span class="money">￥` + spl[i].money + `</span>
				`).appendTo(".xiala")
			}
		})
		$("<div class='food'></div>").html(`
					<span>配送费</span>
					<span class="money">￥3</span>
			`).appendTo(".xiala")
	}
	
		
	// 购买商品信息  下拉
	$(".xiala").css("display", "none")
	$(".name").click(function() {
		$(".xiala").slideToggle()
	})
	
	$(".go").click(function(){
		window.location.href = "pay.html"
	})
})